package com.jiedeng.mapper.provider;

/**
 * 任务管理sql
 *
 * @author zhouyb
 */
public class TaskSqlProvider {
    /**
     * 评分查找责任单位
     *
     * @param projectId
     * @param checkItemId
     * @param checkItemRuleId
     * @return
     */
    public String findResponsibilityCropSql(long projectId, long checkItemId, long checkItemRuleId,String checkId) {
        String sql = "SELECT DISTINCT " +
                " tpc.Corp_ID,tcir.Corp_WeightLevel,tcir.Post_ID,tc.Corp_Caption " +
                " FROM " +
                " T_checkItemRule tcir " +
                " LEFT JOIN t_project_corp tpc ON tcir.Corp_Prop_ID = tpc.Corp_Prop_ID " +
                " LEFT JOIN t_corp tc on tc.Corp_ID = tpc.Corp_ID " +
                " LEFT JOIN (select Corp_ID from t_checkcount tcc where tcc.Check_ID='"+checkId+"') a " +
                "  ON tc.Corp_ID = a.Corp_ID " +
                " WHERE " +
                " tpc.Project_ID = " + projectId +
                " AND tcir.checkItem_ID = " + checkItemId +
                " AND tcir.id = " + checkItemRuleId+
                " ORDER BY a.Corp_ID desc ";
        return sql;
    }

    /**
     * 评分查找责任单位人
     *
     * @param projectId
     * @param corpId
     * @return
     */
    public String findResponsibilityPersonSql(long projectId, long corpId, long postId,String checkId) {
        String sql = "select DISTINCT tp.* from  t_project_person tpp  " +
                " LEFT JOIN t_person tp on tp.Person_ID = tpp.Person_ID " +
                " LEFT JOIN (select Person_ID from t_checkcount tcc where tcc.Check_ID='"+checkId+"') a " +
                "  ON tp.Person_ID = a.Person_ID " +
                " where tpp.Project_ID = " + projectId + " and tp.Corp_ID= " + corpId + " and tpp.Post_ID = " + postId+
                " ORDER BY a.Person_ID desc ";
        //System.out.println(sql);
        //LEFT JOIN t_checkitemrule tc on  tpp.Post_ID= tc.Post_ID
        return sql;
    }
}
